package com.teaching.Service.ServiceImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.Common.Utils;
import com.teaching.Entity.Teacher;
import com.teaching.Mapping.TeacherMapper;
import com.teaching.Service.TeacherService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Set;

@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements TeacherService {

    @Override
    public List<Teacher> ListSize(HashMap<String, Object> data) {
        int size = Utils.getInteger(data, "size");
        String className = Utils.getString(data, "className");
        String teacherName = Utils.getString(data, "teacherName");
        String teacherAddress = Utils.getString(data, "teacherAddress");
        Page<Teacher> teacherPage = new Page<>(1, size);
        LambdaQueryWrapper<Teacher> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(className), Teacher::getTeacherClass, className);
        queryWrapper.like(StringUtils.isNotEmpty(teacherName), Teacher::getTeacherName, teacherName);
        queryWrapper.like(StringUtils.isNotEmpty(teacherAddress), Teacher::getTeacherAddress, teacherAddress);
        Page<Teacher> page = this.page(teacherPage, queryWrapper);
        return page.getRecords();
    }

    @Override
    public List<Teacher> ListSize2(Teacher teacher) {
        return null;
    }


}
